#include "scancamerathread.h"

ScanCameraThread::ScanCameraThread(QObject *parent)
    : QThread{parent}
    , m_pCameras(NULL)
{
    m_bHasSomeClosed = true;
}

void ScanCameraThread::run() {
    while(m_bHasSomeClosed){
        if(m_pCameras != NULL){
            m_bHasSomeClosed = false;
            foreach (Camera* pCamera, *m_pCameras) {
                if(!pCamera->IsOpen()){
                    if(GX_STATUS_SUCCESS == pCamera->OpenDevice()){
                        pCamera->ConfigCaptureVideo();
                        pCamera->StartSnap();
                    }else{
                        m_bHasSomeClosed = true;
                    }
                }
            }

            QThread::sleep(1000);
        }else{
            m_bHasSomeClosed = false;
        }
    }

    qDebug() << "ScanCameraThread Exit!!!!!!!!!!!!!!!!";
}
